#ifndef AUDIOTHREAD_H
#define AUDIOTHREAD_H

#include <mutex>
#include <list>
#include <QThread>
#include "MYDecodeThread.h"

struct AVCodecParameters;
class AudioPlay;
class MYResample;

class MYAudioThread : public MYDecodeThread
{
public:
    MYAudioThread();
    virtual ~MYAudioThread();

    // 当前音频播放的pts
    long long pts = 0;
    // 打开，不管成功与否都清理
    virtual bool Open(AVCodecParameters *para, int sampleRate, int channels);
    // 停止线程，清理资源
    virtual void Close();
    // 清理资源
    virtual void Clear();

    void run();

    // 暂停
    void SetPause(bool isPause);
    bool isPause = false;
    // 改变音量
    void SetVolume(double newVolume);
protected:
    // amux 锁res
    std::mutex amux;
    AudioPlay *ap = 0;
    MYResample *res = 0;
};

#endif // AUDIOTHREAD_H
